import 'package:trade/common/network/base/base_http.dart';
import 'package:trade/common/network/single_protocol.dart';
import 'package:trade/data/bean/user_info_bean.dart';
import 'package:trade/data/model/user_model.dart';

class LoginApi extends SingleProtocol<LoginApi> {

  final String phone;
  final String password;
  final UserModel userModel;

  LoginApi({
    required this.phone,
    required this.password,
    required this.userModel,
  });

  @override
  String get api => "/user/login";

  @override
  Map<String, dynamic>? get arguments => {
        "phone": phone,
        "password": password,
      };

  @override
  void onParse(data) {
    /// 若请求成功，在这解析保存token和用户信息
    userModel.info =
        UserInfoBean(phone: phone, password: password, token: data);
  }

  @override
  void onParseError(TDError error) {

  }
}
